﻿@using IEMSOFT.EasyHotel.Admin.Models;
@using IEMSOFT.EasyHotel.Common;
@using IEMSOFT.Foundation;
@{
    ViewBag.Title = "EasyHotel酒店管理系统 Powered by IEMSOFT";
}
@{
    var currentUser = ViewBag.CurrentUser as UserModel;
    var str = "";
}
@section header
{
    <style type="text/css">
        .easyui-accordion ul
        {
            list-style-type: none;
            margin: 0px;
            padding: 5px;
        }

            .easyui-accordion ul li
            {
                padding: 0px;
            }

                .easyui-accordion ul li a
                {
                    line-height: 20px;
                    font-size: 16px;
                    color: #0099FF;
                }

                .easyui-accordion ul li div
                {
                    margin-top: 2px;
                }

                    .easyui-accordion ul li div img
                    {
                        width: 14px;
                        height: auto;
                        margin-right: 5px;
                        margin-top: 10px;
                    }

                    .easyui-accordion ul li div.hover
                    {
                        border: 1px dashed #99BBE8;
                        background: #E0ECFF;
                        cursor: pointer;
                    }

                        .easyui-accordion ul li div.hover a
                        {
                            color: #416AA3;
                        }

                    .easyui-accordion ul li div.selected
                    {
                        border: 1px solid #99BBE8;
                        background: #E0ECFF;
                        cursor: default;
                    }

                        .easyui-accordion ul li div.selected a
                        {
                            color: #416AA3;
                            font-weight: bold;
                        }
    </style>
}
<div region="north" split="true" style="overflow: hidden; height: 40px; background: #D2E0F2 repeat-x center 50%; color: #fff; font-size: 14px">
    <div style="text-align: center; font-weight: bold; font-size: 16px; color: #000000; padding-top: 5px">
        @if (string.IsNullOrEmpty(currentUser.SubHotelName))
        {
            str = string.Format("欢迎{0}使用", currentUser.UserName);
        }
        else
        {
            str = string.Format("欢迎{0}使用(分店:{1})", currentUser.UserName, currentUser.SubHotelName);
        }
        @str
    </div>
</div>
<div region="south" style="height: 20px; background: #D2E0F2;">
    <div style="text-align: center; font-weight: bold; font-size: 14px">
        EasyHotel 1.0.0 Powered by IEMSOFT
    </div>
</div>
<div region="west" split="true" title="导航菜单" style="width: 180px; overflow: hidden;" data-options="iconCls:'icon-large-clipart'">
    <div id="menu" class="easyui-accordion" fit="true" border="false">
        @if (currentUser.RoleId == RoleType.Reception.ToInt())
        {
            <div title="前台" style="overflow: auto; padding: 10px;" iconcls="icon-man">
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/back.png" />
                            <a target="mainFrame" href="javascript:void()">登出</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/pencil.png" />
                            <a target="mainFrame" href="javascript:void()" name="linkReception" parentmenu="前台" url="/room/roomstatus?m=reception">房间状态</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/large_chart.png" />
                            <a target="mainFrame" href="javascript:void()" parentmenu="前台" url="/report/index?m=reception">报表统计</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/edit_add.png" />
                            <a target="mainFrame" href="javascript:void()" parentmenu="前台" url="/account/updatepassword">修改密码</a>
                        </div>
                    </li>
                </ul>
            </div>
        }
        else if (currentUser.RoleId == RoleType.HotelManager.ToInt())
        {
            <div title="店长" style="overflow: auto; padding: 10px;" iconcls="icon-man">
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/back.png" />
                            <a target="mainFrame" href="javascript:void()">登出</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/pencil.png" />
                            <a target="mainFrame" href="javascript:void()" name="linkReception" parentmenu="店长"
                                url="/room/roomstatus?m=hotelmanager">房间状态</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/edit_add.png" />
                            <a target="mainFrame" href="javascript:void()" parentmenu="店长" url="/room/index">房间管理</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/large_chart.png" />
                            <a target="mainFrame" href="javascript:void()" parentmenu="店长" url="/report/index?m=hotelmanager">报表统计</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/edit_add.png" />
                            <a target="mainFrame" href="javascript:void()" parentmenu="店长" url="/account/updatepassword?m=hotelmanager">修改密码</a>
                        </div>
                    </li>
                </ul>
            </div>
        }
        else if (currentUser.RoleId == RoleType.GroupLeader.ToInt())
        {
            <div title="集团" style="overflow: auto; padding: 10px;" iconcls="icon-large-smartart">
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/back.png" />
                            <a target="mainFrame" href="javascript:void()">登出</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/large_chart.png" />
                            <a target="mainFrame" href="javascript:void()" parentmenu="集团" name="linkReception"
                               url="/room/roomstatus?subHotelId=1&m=groupleader">入住状态</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/edit_add.png" />
                            <a target="mainFrame" href="javascript:void()" parentmenu="集团" url="/grouphotel/index">集团信息管理</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/edit_add.png" />
                            <a target="mainFrame" href="javascript:void()" parentmenu="集团" url="/subhotel/index">分店管理</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/edit_add.png" />
                            <a target="mainFrame" href="javascript:void()" parentmenu="集团" url="/account/index?m=groupleader">账号管理</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/edit_add.png" />
                            <a target="mainFrame" href="javascript:void()" parentmenu="集团" url="/travelagency/index">旅行社管理</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/edit_add.png" />
                            <a target="mainFrame" href="javascript:void()" parentmenu="集团" url="/roomtype/index">房型管理</a>
                        </div>
                    </li>
                </ul>
                <ul>
                    <li>
                        <div>
                            <img src="~/Content/jquery-easyui-1.4/themes/icons/large_chart.png" />
                            <a target="mainFrame" href="javascript:void()" parentmenu="集团" url="/report/index?m=groupleader">报表统计</a>
                        </div>
                    </li>
                </ul>
            </div>
        }
    </div>
</div>
<div region="center" id="mainPanel" style="background: #eee; overflow: hidden;">
    <div id="tabs" class="easyui-tabs" fit="true" border="false">
    </div>
</div>

@section scripts
{
    <script type="text/javascript">
        $(function () {
            InitLeftMenu();
            $('body').layout();
            var url = '@ViewBag.ReturnUrl';
            var selector = "a[url='" + url + "']";
            if ($(selector).length == 1) {//登陆超时后，退出重新登陆需重新回到刚才页面
                var parentMenu = $(selector).attr('parentmenu');
                $('#menu').accordion('select', parentMenu);
                $(selector).click();
            }
            else {
                $('#menu').accordion('select', '房间状态');
                $('a[name="linkReception"]').click();
            }
        })

        function InitLeftMenu() {
            $('.easyui-accordion li a').click(function (event) {
                if ($(this).text() == '登出') {
                    top.location.href = '/account/logout';
                    return;
                }
                var tabTitle = $(this).attr('parentmenu') + '->' + $(this).text();
                var url = $(this).attr("url");
                addTab(tabTitle, url);
                $('.easyui-accordion li div').removeClass("selected");
                $(this).parent().addClass("selected");
            }).hover(function () {
                $(this).parent().addClass("hover");
            }, function () {
                $(this).parent().removeClass("hover");
            });
        }
        function addTab(subtitle, url) {
            if (!$('#tabs').tabs('exists', subtitle)) {
                $('#tabs').tabs('add', {
                    title: subtitle,
                    content: createFrame(url),
                    closable: true,
                    width: $('#mainPanel').width() - 10,
                    height: $('#mainPanel').height() - 26
                });
            } else {
                $('#tabs').tabs('close', subtitle);
                addTab(subtitle, url);
            }
        }
        function createFrame(url) {
            var s = '<iframe name="mainFrame"  frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
            return s;
        }
    </script>
}